/*子页面需要填写的内容：*/
function child(facility_id){

	var content = "";
	content +='<tr>'
			+'<td>'
			+'<a class="layui-btn layui-btn-sm" onclick="changeStatus(0,'+facility_id+')">正常</a>'
			+'</td>'
			+'<td>'
			+'<a class="layui-btn layui-btn-sm layui-btn-danger" onclick="changeStatus(1,'+facility_id+')">损坏</a>'
			+'</td>'
			+'<td>'
			+'<a class="layui-btn layui-btn-sm layui-btn-warm" onclick="changeStatus(2,'+facility_id+')">维修中</a>'
			+'</td>'
			+'</tr>';
	$("#facilityStatus").html(content);
	
//该方法相当于入口函数，进入该子页面即执行
}

//删除
function delCustomList(_this){
	
	layui.use(['form','laydate'], function() {
		layer.confirm('确定要删除么？', {
			btn: ['确定', '取消'] //按钮
		}, function() {
			$(_this).parent().parent().remove();
			layer.msg('删除成功', {
				icon: 1
			});
		}, function() {
			layer.msg('取消删除', {
				time: 2000 //2s后自动关闭
			});
		});
	});
}

function changeStatus(status,facility_id){
	$.ajax({
		url:"../../facility/updateStatus",
		type:"post",
		dataType:"json",
		
		data:{
			"status":status,
			"facility_id":facility_id
		},
		success:function(data){
			if(data==0){
				alert("修改失败");
				parent.layer.closeAll();//关闭所有的弹窗
				 parent.location.reload();
			}else{
				
				parent.layer.closeAll();//关闭所有的弹窗
				 parent.location.reload();
			}
			
			
			
		}
	});
}



